import axios from 'axios';
import Vue from 'vue';

let _axios = axios.create({
    baseURL:"http://47.115.51.185:8081",
    // baseURL:"https://apis.netstart.cn/music",
    timeout:3000,
    // headers:{}
});

_axios.interceptors.request.use(function(config){
    return config
},function(err){
    return Promise.reject(err);
});

_axios.interceptors.response.use(function(response){
    if(response.data){
        if(response.data.data){
            return response.data.data;
        }
        return response.data;
    }
    return response;
},function(error){
    return Promise.reject(error);
});

let axiosPlus={};
axiosPlus.install=function(Vue){
    Vue.axios=_axios;
    Vue.prototype.axios=_axios;
    Vue.prototype.$axios=_axios;
    Vue.prototype.request=_axios;
    Vue.prototype.$request=_axios;
}
Vue.use(axiosPlus);
export default axiosPlus;